<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>认证首页</title>
		<link rel="stylesheet" type="text/css" href="../../css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="../../css/api.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/base.css">
		<link rel="stylesheet" type="text/css" href="../../css/news.css">
	

		<style>
			body {
				background: #FFFFFF;
				margin: 0px;
			}

			.img_background-image {
				display: block;
				/* width: 130px; */
		
				/* height: 100%; */
				background-image: url(../../image/course_placehoder.png);
				background-size: 130px 100%;
					border: 1px solid #fff;
				border-radius: 4px;
			}
			.left10 {
				padding-left: 10px;
			}
			.right10 {
				padding-right: 10px;
			}
				.img_width {
			width: 14px;
				    position: relative;
              top: 2px;
			}
			.divstyle{
			   padding-left: 10px;
			   padding-right: 10px;
		       background-color: #FFFFFF;
			}
		.rotation-img{
			width: 100%;
			min-height: 190px;
			background-image: url(../../image/course_placehoder.png);
			background-size: 100% 100%;
			display: block;
		}
		.mui-slider-indicator .mui-indicator{
			background-color: #e6e3e3;
		}
		.base_left_item {
	    position: fixed;
	    top: 22px;
	    left: 0;
	    z-index: 10;
        }
	.base_back_icon {
	    height: 30px;
	    position: absolute;
	    top: 7px;
	    left: 7px;
	    margin-top: 0;
	}
	 .padding_left5{    
	    padding-left: 5px;
	 }
	  	/**默认显示4行*/
.according-2-rows{
 	 
 	overflow: hidden;
 	text-overflow: ellipsis;
 	display: -webkit-box;
 	-webkit-line-clamp: 2;
 	-webkit-box-orient: vertical;
 	}
 		.dayiImgDiv{
	 	  background: url(../../image/icon_dayi02.png);
	 	   background-size: 100% 100%;
	 	   	height: 84px;
	 	}
		</style>
	</head>
	<body>
		<div id="main" style="background-color: #f3f5f7;"  hidden="hidden" >
		<a id="btnBack" class="base_left_item" href="#" onclick="backClick()">
        <img class="base_back_icon" src="../../image/icon_bgback.png" alt="">
    </a>
		<!-- 轮播图 -->
		<div id="train_slider" class="mui-slider rotation-div" >
			<div id="rotation" class="mui-slider-group mui-slider-loop">
				
			</div>
		<div id="noRotation"  hidden="hidden">
				<div class="rotation-cell">
					<a href="#" style="    display: block;">
						<img class="rotation-img" src="../../image/firstNewsTitls2.png">
					</a>
				</div>
			</div>
			<div id="pageControl" class="mui-slider-indicator">
			
			</div> 
		</div>
		
			<div style="background-color: #ffffff;" class="clearfix">
			<div  id="dayi" style="position: relative; display: none"  onclick="openwork()">
				<div  id="hdongDiv" class="dayiImgDiv" >	
				</div>
			</div>
				<div style="line-height: 40px;"class="divstyle">
					<img src="../../image/icon_system.png"  class="img_width"/><samp class="base_dark_grey_shallow base_content_font padding_left5">认证体系</samp>
					<span class="right  base_dark_grey_shallow base_tag_font" onclick='onclcick_win(3)'>更多 </span>
				</div>
				<ul class="mui-table-view" id="system_id" ></ul>
			
				<div style="height: 8px;width: 100%;  background-color: #f3f5f7;"></div>
				<div class=" clearfix">
					<div style=" line-height: 40px;" class="divstyle">
						<img src="../../image/icon_job.png"  class="img_width"/><samp class="base_dark_grey_shallow base_content_font padding_left5 ">推荐岗位</samp>
						<span class="right base_dark_grey_shallow base_tag_font " onclick='onclcick_win(1)'>更多 </span>
					</div>
	
				 <div id="div_jobs" style="margin-left: 10px;margin-right: 10px;">
				</div>
		
			</div>
			<div style="height: 8px;width: 100%;  background-color: #f3f5f7;"></div>
			
				<div style=" line-height: 40px;" class=" divstyle">
					<img src="../../image/icon_ews.png"  class="img_width"/><samp class="base_dark_grey_shallow base_content_font padding_left5 ">热门资讯</samp>
					<span class="right  base_dark_grey_shallow base_tag_font" onclick='onclcick_win(2)'>更多 </span>
				</div>
				<ul class="mui-table-view" id="div_news" ></ul>
		

		</div>
		<div class="noSign"   id="noData"  hidden="hidden">
			<img src="../../image/icon_img.png" width="60%">
			<p class="font16 top_15 base_dark_grey" >
				暂无数据
			</p>
		</div>
		<div class="loadFailure"  id="noNet" hidden="hidden">
			<img src="../../image/icon_img01.png" width="60%">
			<p class="" >
				数据加载失败
			</p>
			<p>
				请检查您的网络
			</p>
			<button type="button" class="mui-btn mui-btn-outlined" onclick="RefreshData()">
				重新加载
			</button>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/common.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/getToken.js"></script>
    <script type="text/javascript" src="../../script/mui.min.js"></script>
    <script type="text/javascript" src="../../script/ui.js"></script>
	<script src="../../script/jquery.min.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>

	<script type="text/javascript">
		var clic = false;
		var rotationArr = new Array();//轮播图数据
		var job_data = '';
		var news_data = '';
		var course_data = '';
		var vid ='';//章节id
		var pid ='';//计划id
		apiready = function() {
			initHeaderUI();
		    showProgress();
			api.setScreenOrientation({
				orientation : "portrait_up"
			});
			setupNotifi();

			loaddata();
		};
		

		function setupNotifi() {
			api.addEventListener({
				name : 'showMessageFrameNotifi'
			}, function(ret, err) {
				//coding...
				 SendBehaviorTrajectoriesNotifi1(0, '认证首页', '118',api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname,  document.title);
				showHomeFrame();
			});
			api.addEventListener({
				name : 'hideMessageFrameNotifi'
			}, function(ret, err) {
				//coding...
				 if(api.pageParam.type=='Certification'){
              SendBehaviorTrajectoriesNotifi1(1, '认证首页', '118',api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname,  document.title);
            }
				hideHomeFrame();
			});
				api.addEventListener({
		   name: 'baiduWebVideoBackNotifi'
		   }, function(ret, err) {
//		    var isfile = ret.value.isfile;
//		    var vid = ret.value.vid;
		});
		}

		function showHomeFrame() {
			api.setFrameAttr({
				name : 'Home_frame',
				hidden : false
			});
			api.setFrameAttr({
				name : 'HomePage_back',
				hidden : false
			});
		}

		function hideHomeFrame() {
			api.setFrameAttr({
				name : 'Home_frame',
				hidden : true
			});
			api.setFrameAttr({
				name : 'HomePage_back',
				hidden : true
			});
		}

		function onclcick_win(type) {
			if (type == 1) {
				api.sendEvent({
					name : 'jumpPage',
					extra : {
						page : 1
					}
				});
			} else if (type == 2) {
				api.sendEvent({
					name : 'jumpPage',
					extra : {
						page : 2
					}
				});
				api.sendEvent({
	                name:'jumpToNews',
	                extra : {
						type : 2
					}
                });
				
			}else if (type == 3) {//认证体系
				api.sendEvent({
					name : 'jumpPage',
					extra : {
						page : 2
					}
				});
				api.sendEvent({
	                name:'jumpToNews',
	                extra : {
						type : 3
					}
                });
				
			}
			
		}

		//加载失败点击了刷新按钮
		function RefreshData() {
			$('#noNet').hide();
			//加载最新数据
			loaddata();
		}

		//加载数据
		function loaddata() {
			
			var params = {
				uid : $api.getStorage('cfnetppuid'),  
//              uid : 119039,
				jid : jid = $api.getStorage('cfnetppjxid'),
			};
			cfnetppPOST(url_getApproveList, params, true, function(data, status) {
				api.hideProgress();
//				 alert("教师端轮播"+JSON.stringify(data))
				if (status == 'success') {
					if (data.code == 200) {
					$('#main').show();
						var list = data.data;
//						   multiplePicturesCache({
//							   picArr : list.Imge,//包含图片数组
//							   picKey : 'picpath',//图片对应的字段
//							   isOriginals : 1 //是否源图1源图0缩略图，不传默认缩略图
//							}, function(imageArr){
//	                         ScrollPicture(imageArr);
//							});
                        
//						ScrollPicture(list.Imge);
                           rotationArr=list.Imge;
                           if(rotationArr.length>0)
                           	setupRotationData();

						if (list.jobs.length > 0) {
							job_data = list.jobs;
							tixi_data = list.tixi;
							news_data = list.news;
							news(tixi_data,tixi_data.length,1);
							jobs(job_data, job_data.length);
							news(news_data,news_data.length,2);
							var actionData = list.action;
							 
							if(actionData.length > 0){
		                     isppt(actionData[0]);//ppt大赛
		                     }
						}
					} else {
						$('#main').hide();
						$('#noData').show();
						$('#noNet').hide();
					}
				} else {
					$('#main').hide();
					$('#noData').hide();
					$('#noNet').show();
				}
			});
		}
		        	//设置轮播图数据
	function setupRotationData(){

		if (rotationArr.length == 1) {
			var rotationHtml = '';
			rotationHtml = noRotationHtmlString(0, rotationArr[0]);
			$('#noRotation').html(rotationHtml);
			$('#noRotation').show();
			$('#rotation').hide();
		}else{
			var rotationHtml = '';
			//额外增加的一个节点(循环轮播：第一个节点是最后一张轮播)
			var lastIndex = rotationArr.length - 1;
			var rotationLastData = rotationArr[lastIndex];
			rotationHtml += firstLastImgHtml(lastIndex, rotationLastData);
			//遍历数组
			for (var i = 0; i < rotationArr.length; i++) {
				var rotationData = rotationArr[i];
				rotationHtml += rotationHtmlString(i, rotationData);
			}
			//额外增加的一个节点(循环轮播：最后一个节点是第一张轮播)
			var firstIndex = 0;
			var rotationFirstData = rotationArr[firstIndex];
			rotationHtml += firstLastImgHtml(firstIndex, rotationFirstData);
			
			//设置轮播图代码
			$('#rotation').html(rotationHtml);
		
			//设置page Control
			$('#pageControl').html(pageControlHtml(rotationArr.length));
			
			//设置自动轮播
			setupAutoRotation();
			$('#noRotation').hide();
			$('#rotation').show();
				
		}
//		//设置轮播图点击事件
		setupRotationCellClick();
	}
	function setupAutoRotation(){
		var slider = mui("#train_slider");
		slider.slider({
			interval: 3000
		});
	}
		//分页html
	function pageControlHtml(count){
		var pageControl = '';
		pageControl += '<div class="mui-indicator mui-active"></div>';
		for (var i = 1; i < count; i++) {
			pageControl += '<div class="mui-indicator"></div>';
		}
		return pageControl;
	}
	//轮播图首尾
	function firstLastImgHtml(index, data){
		return '<div index="'+index+'" class="rotation-cell mui-slider-item mui-slider-item-duplicate">'+
					'<a href="#">'+
						'<img class="rotation-img" src="'+data.picpath+'">'+
					'</a>'+
				'</div>';
	}
	//轮播图
	function rotationHtmlString(index, data){
		return '<div index="'+index+'" class="rotation-cell mui-slider-item">'+
					'<a href="#">'+
						'<img class="rotation-img" src="'+data.picpath+'">'+
					'</a>'+
				'</div>';
	}
	//不轮播的cell
	function noRotationHtmlString(index, data){
		return '<div index="'+index+'" class="rotation-cell">'+
				
						'<img class="rotation-img" src="'+data.picpath+'">'+
				
				'</div>';
		}

	function setupRotationCellClick() {
		$('.rotation-cell').unbind('click');
		$('.rotation-cell').click(function(event) {
			if (api.connectionType == "none") {
				api.toast({
					msg : '网络异常，请检查网络！'
				});
				return;
			}
			var index = $(this).attr('index');
		
			var rotationData = rotationArr[parseInt(index)];
			var url1 = rotationData.appadurl;
	       
			if (url1 != '' && url1 != null && url1 != undefined) {
				if (url1.indexOf("http") == -1) {//包含
					return;
				}
			}
		
			var type = url1.indexOf(".mp4");
			if (type > 0) {//包含mp4
				var connectionType = api.connectionType;
				if (connectionType != 'wifi' && connectionType != 'none') {
					api.confirm({
						title : '提示',
						msg : '您当前处于移动数据网络下，是否继续播放',
						buttons : ['确定', '取消']
					}, function(ret, err) {
						var index = ret.buttonIndex;
						if (index == 1) {//确定
							toPlayVideo(url1);
						}
					});
			  }else{
			  toPlayVideo(url1);
			  }
			}else{
		
			var pageParam =  {
				url: isfreelogin(rotationData.islogin,url1),
				title : rotationData.cname,
				shareurl :url1,
				}
			api.openWin({useWKWebView:true,
				name : 'indexLunDetailsWindow',
				url : 'indexLunDetailsWindow.html',
				pageParam : pageParam
			});
			}
           });
            if(api.pageParam.type=='Certification'){
              SendBehaviorTrajectoriesNotifi1(1, '认证首页', '118',api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname,  document.title);
            }
	}



		function toPlayVideo(url) {
//			pushToBaiDuPlayer(0, "", url, "长风物流认证介绍");
        api.openWin({useWKWebView:true,
        name: 'BaiDuWebVideo',
        url: '../Study/BaiDuWebVideo.html',
        pageParam: {
         title: "长风物流认证介绍",
            url: url,
            token: '',
            vid:0,
            isfile: 0
        },
        slidBackEnabled: false
    });


		
		}

		//岗位
		function jobs(datas, len) {

			var jobs = '';
			for (var i = 0; i < len; i++) {
				var data = datas[i];
				var div='';
				if(i==0||i==2){
				  div='<div  class= "div_img_left right10" onclick="CheckJobClick(' + i + ')">'
				}else{
				   div='<div  class= "div_img_left left10" onclick="CheckJobClick(' + i + ')">'
				}
				var job = div
				 + '<img   src="../../image/icon_renzheng' + i + '.png" class="td_left img_background-image" onerror="Imgnofind()"/>' + '<p  class="base_content_font base_black_grey padding_left_right5">'
				  + data.quarter + '</p>' + '</div>';
				jobs = jobs + job;
			}
			$('#div_jobs').html(jobs);
		}






      function  news(datas,len,type){
              
	       var news='';
	        for(var i=0;i<len;i++){
	           var data = datas[i];
	            var imgPath= data.picpath;
	          if(imgPath!=null&&imgPath!=""){   
//		       var newhtml='<li class="mui-table-view-cell" onclick="CheckNewClicks(' + i+')"><div class="item_left div_title_css_left" style="position:relative;">'+
//								'<span class="item_text_title base_content_font base_black_grey according-2-rows">'+escape2Html(data.title).replace(/&/g,'')+'</p>'+
//								'<span class="item_text_bz base_grey base_tag_font" style="position:absolute; bottom:0px;">'+getCurrentDay(data.ctime)+'&nbsp;&nbsp;'+data.author+'</span>'+
//							'</div>'+
//							'<div class="item_right div_title_css_left">'+
//								'<div class="item_right_s course-img"><img src="'+imgPath+'" onerror="Imgnofind()" /></div>'+
//							'</div>'+
//						'</div>'+
//						'</li>';
			 var newhtml=	'<li class="mui-table-view-cell train-cell"  onclick="CheckNewClicks(' + i+','+type+')">'+
					'<img class="hot-train-image" src="'+imgPath+'">'+
					'<div class="hot-train-title-div">'+
						'<p class="base_black_grey base_content_font train-title">'
							+escape2Html(data.title).replace(/&/g,'')+
						'</p>'+
						'<p class="base_grey base_tag_font hot-train-time">'+
							getCurrentDay(data.ctime)+'&nbsp;&nbsp;'+data.author+
						'</p>'+
					'</div>'+
				'</li>';
			}else{
			  var newhtml='<li class="mui-table-view-cell"><p class="item_text_title base_content_font base_black_grey" onclick="CheckNewClicks(' + i+')">'+data.title+'</p>'+
				        '<p class="item_text_bz base_grey base_tag_font">'+getCurrentDay(data.ctime)+data.author+'&nbsp;&nbsp;'+'</p>'+
							'</div>'+
			           '</li>';
			 }
				news = news+newhtml;
	        }
	     
			if(type==1){
			   $("#system_id").html(news );
			}else{
			   $("#div_news").html(news );
			}
       
        }
		//新闻详情
		function CheckNewClicks(i,type) {
		if(type==1){
			  	var data = tixi_data[i];
			}else{
			  var data = news_data[i];
			}
		
			api.openWin({useWKWebView:true,
				name : 'certificationDetails',
				url : '../News/certificationDetails.html',
				pageParam : {
					news : data,
					Newstype:'HotNews',
					sourceurl : window.location.pathname,
					sourcetitle : document.title,
					
				},
			});
			 if(api.pageParam.type=='Certification'){
              SendBehaviorTrajectoriesNotifi1(1, '认证首页', '118',api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname,  document.title);
            }
		}

		
		//岗位详情
		function CheckJobClick(i) {
			var data = job_data[i];
			api.openWin({useWKWebView:true,
				name : 'Detaila',
				url : '../Quarters/Detaila.html',
				pageParam : {
					id : data.id,
					title : data.quarter,
					sourceurl : window.location.pathname,
					sourcetitle : document.title
				},
			});
			 if(api.pageParam.type=='Certification'){
              SendBehaviorTrajectoriesNotifi1(1, '认证首页', '118',api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname,  document.title);
            }
		}
		
		
		function backClick(){
		 SendBehaviorTrajectoriesNotifi1(1, '认证首页', '118',api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname,  document.title);
		api.closeWin({
        });
		}
		
        function isppt(data){
             $('#dayi').show();
             $("#hdongDiv").css("background-image","url("+data.image+")");
             pid = data.pid;
             vid = data.vid;
        
        }
		
		function openwork(){
		 SendBehaviorTrajectoriesNotifi1(1, '认证首页', '118',api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname,  document.title);
		  winName = "new_student_study_freecourse_homeworks";
			winPath = "../Study/new_student_study_freecourse_homeworks.html";
			pageParam = {
				chapterid :vid,
				pid : pid,
				sourceurl : window.location.pathname,
			    sourcetitle : document.title
			};
			api.openWin({useWKWebView:true,
		    name: winName,
		    url: winPath,
		    pageParam: pageParam
		});
		}
	</script>
</html>